package com.ccloud.im.handler;

import com.ccloud.common.im.enums.SocketThemeEnum;
import com.ccloud.common.im.handler.CIMRequestHandler;
import com.ccloud.common.im.model.CIMMsg;
import com.ccloud.common.im.model.CIMSession;
import lombok.extern.slf4j.Slf4j;

/**
 * CIM自定义业务处理器
 *
 * @author scylla
 * @version V1.0
 * @project ccloud-parent
 * @title 业务处理器
 * @package com.ccloud.im.handler
 * @since 2022/8/2 2:57 下午
 */
@Slf4j
public class BusinessHandler implements CIMRequestHandler {

    @Override
    public void process(CIMSession session, CIMMsg cimMsg) {
        try {
            //todo 根据发送的消息主题进行逻辑编排并发送。
            String theme = cimMsg.getTheme();

            //主题:
            if (theme.equals(SocketThemeEnum.CLIENT_SEND_MSG_TO_CHANNEL.getCode())) {
                // todo 分发不同主题

            } else if (theme.equals(SocketThemeEnum.SERVER_COUNT_UNREAD_MSG.getCode())) {
                // todo 分发不同主题

            }

        } catch (Exception exception) {
            log.error("Business Handler exception occurred", exception);
        }

    }

}